{extend name="app/admin/view/base.html"/}
{block name="resources"}
<style>
    .ns-card-brief:nth-child(1){
        margin-top: 0;
    }
    .layui-card-body{
        display: flex;
        flex-wrap: wrap;
        padding-bottom: 0 !important;
        padding-left: 50px !important;
        padding-right: 50px !important;
    }
    .layui-card-body .content{
        width: 33.3%;
        margin-bottom: 30px;
        display: flex;
        flex-wrap: wrap;
        flex-direction: column;
        justify-content: center;
    }
    .layui-card-body .money{
        font-size: 20px;
        color: #000;
        font-weight: bold;
        margin-top: 10px;
        max-width: 250px;
    }
    .layui-card-body .subhead{
        font-size: 12px;
        margin-left: 3px;
        cursor: pointer;
    }
</style>

{/block}
{block name='main'}

<div class="layui-card ns-card-common ns-card-brief">
    <div class="layui-card-header">
        <div>
            <span class="ns-card-title">分站结算</span>
        </div>
    </div>
    <div class="layui-card-body">
        <div class="content">
            <p class="title">分站订单总分成（元）</p>
            <p class="money">{$account_info.order_commission}</p>
        </div>
        <div class="content">
            <p class="title">分站店铺入驻总抽成（元）</p>
            <p class="money">{$account_info.shop_commission}</p>
        </div>

    </div>
</div>

<!-- 筛选面板 -->
<div class="ns-single-filter-box">
    <div class="layui-form">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" name="start_time" id="start_time" placeholder="开始时间" class="layui-input" autocomplete="off" readonly>
                <i class="ns-calendar"></i>
            </div>
            <div class="layui-input-inline end-time">
                <input type="text" name="end_time" id="end_time" placeholder="结束时间" class="layui-input" autocomplete="off" readonly>
                <i class="ns-calendar"></i>
            </div>
            <button class="layui-btn layui-btn-primary" lay-submit lay-filter="search">搜索</button>
        </div>
    </div>
</div>

<div class="layui-tab ns-table-tab" lay-filter="goods_list_tab">

    <div class="layui-tab-content">
        <table id="account_list" lay-filter="account_list"></table>
    </div>

</div>

{/block}
{block name="script"}
<script type="text/html" id="action">
    <div class="ns-table-btn">
        <a class="layui-btn" lay-event="detail">查看</a>
    </div>
</script>

<script type="text/html" id="order_commission">
    <span style="color: red;">￥{{d.order_commission}}</span>
</script>

<script type="text/html" id="shop_commission">
    <span style="color: red;">￥{{d.shop_commission}}</span>
</script>

<script>
    var start_time,end_time;
    layui.use(['laydate','form'], function () {
        var laydate = layui.laydate,
            form = layui.form;
		form.render();

        //开始时间
        laydate.render({
            elem: '#start_time' //指定元素
            ,done: function(value, date, endDate){
                start_time = ns.date_to_time(value);

            }
        });
        //结束时间
        laydate.render({
            elem: '#end_time' //指定元素
            ,done: function(value, date, endDate){
                end_time = ns.date_to_time(value);
            }
        });

        /**
         * 搜索功能
         */
        form.on('submit(search)', function (data) {
            data.field.start_time = start_time;
            data.field.end_time = end_time;
            table.reload({
                page: {
                    curr: 1
                },
                where: data.field
            });
            return false;
        });
    });

    var table = new Table({
        elem: '#account_list',
        url: ns.url("city://admin/settlement/lists"),
        cols: [
            [{
                field:'settlement_no',
                title: '账单编号',
                unresize: 'false',
                width:'17%',
            }, {
                field:'website_num',
                title: '分站数量',
                unresize: 'false',

            }, {
                title: '分站订单分成',
                unresize: 'false',
                align: 'right',
                templet: '#order_commission'

            }, {
                title: '分站店铺入驻分成',
                unresize: 'false',
                align: 'right',
                templet: '#shop_commission'

            }, {
                title: '账期开始时间',
                unresize: 'false',
                templet: function (res){
                    if(res.period_start_time == 0){
                        return '--';
                    }else{
                        return ns.time_to_date(res.period_start_time)
                    }
                }
            }, {
                title: '账期结束时间',
                unresize: 'false',
                templet: function (res){
                    if(res.period_end_time == 0){
                        return '--';
                    }else{
                        return ns.time_to_date(res.period_end_time)
                    }

                }
            },{
                title: '操作',
                toolbar: '#action',
                unresize: 'false',
                width: '8%'
            }]
        ]
    });

    /**
     * 监听工具栏操作
     */
    table.tool(function(obj) {
        var data = obj.data;
        switch (obj.event) {
            case 'detail': //详情
                location.href = ns.url("city://admin/settlement/detail", {"period_id": data.period_id});
                break;
        }
    });

</script>
{/block}